import { Controller, Get, Post, Body, Patch, Param, Delete, UsePipes, ValidationPipe } from '@nestjs/common';
import { SqlTestService } from './sql-test.service';
import { CreateSqlTestDto } from './dto/create-sql-test.dto';
import { UpdateSqlTestDto } from './dto/update-sql-test.dto';

@Controller('sql-test')
export class SqlTestController {
  constructor(private readonly sqlTestService: SqlTestService) { }

  @Post('create')
  @UsePipes(new ValidationPipe()) // 启用局部校验，dto才会生效
  create(@Body() createSqlTestDto: CreateSqlTestDto) {
    return this.sqlTestService.create(createSqlTestDto);
  }

  @Get()
  findAll() {
    return this.sqlTestService.findAll();
  }

  @Get(':id')
  findOne(@Param('id') id: string) {
    return this.sqlTestService.findOne(+id);
  }

  @Patch('/update')
  update(@Body() updateSqlTestDto: UpdateSqlTestDto) {
    return this.sqlTestService.update(updateSqlTestDto);
  }

  @Delete(':id')
  remove(@Param('id') id: string) {
    return this.sqlTestService.remove(+id);
  }
}
